//抓取统计信息
corpApp.controller("StaticsController", ['$scope', 'upserve', function($scope, upserve){
	$scope.keys = [];
	$scope.staticsData = [];
	
	$scope.getNumber = function(str){
		var reg = /[0-9]{1,10}%?/;
		return reg.exec(str)[0];
	}
	
	$scope.getName = function(str){
		return str.substr(0, str.lastIndexOf('('))
	}
	
	$scope.getColorIndex = function(){
		var c = parseInt(Math.random()*7);
		switch(c){
		case 0:
			return 'c0';
			break;
		case 1:
			return 'c1';
			break;
		case 2:
			return 'c2';
			break;
		case 3:
			return 'c3';
			break;
		case 4:
			return 'c4';
			break;
		case 5:
			return 'c5';
			break;
		case 6:
			return 'c6';
			break;
		default:
			return '';
		}
	}
	$scope.getStaticsData = function(){
		var staticsData = new Array();
		var data0 = {
				"计划下发情况":[{"UpcomingSortName":"计划下发情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100101","UpcomingName":"(0)"},{"UpcomingSortName":"计划下发情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100102","UpcomingName":"待下发(0)"},{"UpcomingSortName":"计划下发情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100103","UpcomingName":"已下发(7)"}],
				"计划执行情况":[{"UpcomingSortName":"计划执行情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100101","UpcomingName":"(5)"},{"UpcomingSortName":"计划执行情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100102","UpcomingName":"未填报单位(5)"},{"UpcomingSortName":"计划执行情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100103","UpcomingName":"已填报单位(8)"}],
				"计划调整情况":[{"UpcomingSortName":"计划调整情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100101","UpcomingName":"(5)"},{"UpcomingSortName":"计划调整情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100102","UpcomingName":"待下发(5)"},{"UpcomingSortName":"计划调整情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100103","UpcomingName":"已下发(18)"}],
				"计划执行率":[{"UpcomingSortName":"计划调整情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100101","UpcomingName":"(10%)"},{"UpcomingSortName":"计划调整情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100102","UpcomingName":"未完成(9)"},{"UpcomingSortName":"计划调整情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100103","UpcomingName":"已完成(1)"}]
		};
		var data1 = {
				"预算下发情况":[{"UpcomingSortName":"预算下发情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100101","UpcomingName":"(10)"},{"UpcomingSortName":"预算下发情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100102","UpcomingName":"待下发(10)"},{"UpcomingSortName":"预算下发情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100103","UpcomingName":"已下发(7)"}],
				"预算执行情况":[{"UpcomingSortName":"预算执行情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100101","UpcomingName":"(8)"},{"UpcomingSortName":"预算执行情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100102","UpcomingName":"未填报单位(8)"},{"UpcomingSortName":"预算执行情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100103","UpcomingName":"已填报单位(1)"}],
				"预算调整情况":[{"UpcomingSortName":"预算调整情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100101","UpcomingName":"(1)"},{"UpcomingSortName":"预算调整情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100102","UpcomingName":"待下发(1)"},{"UpcomingSortName":"预算调整情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100103","UpcomingName":"已下发(2)"}],
				"预算执行率":[{"UpcomingSortName":"预算调整情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100101","UpcomingName":"(10%)"},{"UpcomingSortName":"预算调整情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100102","UpcomingName":"未完成(9)"},{"UpcomingSortName":"预算调整情况","UpcomingSortCode":"01001","FunctionID":"#","ObjectCode":"","UpcomingCode":"0100103","UpcomingName":"已完成(1)"}]
		};
		staticsData.push(data0);
		staticsData.push(data1);
		var data = staticsData[menuId];
		for(var key in data){
			$scope.keys.push(key);
		}
		angular.forEach(data, function(val, key){
			var os = {
				k:key,
				h:val.splice(0, 1)[0],
				d:val,
				c:$scope.getColorIndex()
			};
			$scope.staticsData.push(os);
		});
	}
	$scope.getStaticsData();
	
	$scope.getUrl = function(functionId){
		//return $path$+ "/admin/" + functionId;
		return "#";
    }
	
}]);